var XMLHttpFactory = function () {}

XMLHttpFactory.prototype = {
    // 如果真的要调用这个方法，会抛出一个错误，它不能被实例化，只能用来派生子类
    createFactory: function () {
        throw new Error('This is an abstract class')
    }
}

var XHRHandler = function () {
    XMLHttpFactory.call(this)
}

XHRHandler.prototype = new XMLHttpFactory()
XHRHandler.prototype.constructor = XHRHandler 
// 重新定义createFactory方法
XHRHandler.prototype.createFactory = function () {
    var XMLHttp = null
    if (window.XMLHttpRequest) {
        XMLHttp = new XMLHttpRequest()
    } else if (window.ActiveXObject) {
        XMLHttp = new ActiveXObject('Microsoft.XMLHTTP')
    }
    return XMLHttp
}